package com.bjpowernode.crm.workbench.web.controller;

import com.bjpowernode.crm.workbench.service.TranService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * 处理统计请求
 *
 * @author 刘逸晖
 */
@Getter
@Setter
@RequestMapping
public class ChartController {

    /**
     * 处理交易相关业务
     */
    private TranService tranService;

    /**
     * 跳转到统计页
     *
     * @return
     */
    @GetMapping("/workbench/chart/transaction/index.do")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView("workbench/chart/transaction/index");
        return modelAndView;
    }

    /**
     * 统计每个阶段的交易数
     *
     * @return 每个阶段的交易数
     */
@PostMapping("/workbench/chart/transaction/queryCountOfTranGroupByStage.do")
    @ResponseBody
    public Object queryCountOfTranGroupByStage() {
        return this.tranService.queryCountOfEveryStage();
    }

}
